package cn.rkylin.oms.goodscost.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.github.pagehelper.PageInfo;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.goodscost.vo.GoodsCostVO;

/**
 * 
 * 类名：GoodsCostDAOImpl <br>
 * 作用：成本管理数据访问层 <br>
 * 创建时间：2018年1月15日 下午4:27:20
 *
 * @author LiPeng
 * @version
 */
@Repository
public class GoodsCostDAOImpl implements IGoodsCostDAO {

    @Autowired
    protected IDataBaseFactory dao;

    private static final String STATEMENT_PAGE_SELECT_BY_CONDITION = "pageSelectGoodsCost";
    private static final String STATEMENT_SELECT_BY_CODE = "selectGoodsCost";
    private static final String STATEMENT_UPDATE_BY_CONDITION = "updateGoodsCost";
    private static final String STATEMENT_INSERT = "insertGoodsCost";
    private static final String STATEMENT_SELECT_BY_SKUID = "selectBySkuId";

    /**
     * queryGoodsCostList:查询商品成品列表
     */
    @Override
    public PageInfo<GoodsCostVO> queryGoodsCostList(int page, int length, GoodsCostVO queryParamVO) throws Exception {
        return dao.findPage(page, length, STATEMENT_PAGE_SELECT_BY_CONDITION, queryParamVO);
    }

    /**
     * getCostChangeList:查询商品成本变更列表
     */
    @Override
    public List<GoodsCostVO> getCostChangeList(GoodsCostVO queryParamVO) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_BY_CODE, queryParamVO);
    }

    /**
     * updateGoodsCost：修改商品成本
     */
    @Override
    public int updateGoodsCost(GoodsCostVO goodsCostVO) throws Exception {
        return dao.update(STATEMENT_UPDATE_BY_CONDITION, goodsCostVO);
    }

    /**
     * insertGoodsCostChanger：新增商品成本变更
     */
    @Override
    public int insertGoodsCostChanger(GoodsCostVO goodsCostVO) throws Exception {
        return dao.insert(STATEMENT_INSERT, goodsCostVO);
    }

    @Override
    public List<GoodsCostVO> queryGoodsCostById(GoodsCostVO goodsCostVO) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_BY_SKUID, goodsCostVO);
    }

}
